<template>
  <div class="MyLove">
    <div class="Love" v-for="item in info" :key="item.id">
      <div
        class="one"
        v-if="item.type == 1 && item.cover.length < 2"
        @click="getid(item.id)"
      >
        <div class="left">
          <div class="top">{{ item.title }}</div>
          <div class="bottom">
            <span class="nickname">{{ item.user.nickname }}</span>
            <span class="number"
              >{{
                item.comments ? item.comments.length : item.comment_length
              }}跟帖</span
            >
          </div>
        </div>
        <div class="right">
          <img
            :src="FixUrl(obj.url)"
            alt=""
            v-for="obj in item.cover"
            :key="obj.id"
          />
        </div>
      </div>
      <div
        class="three"
        @click="getid(item.id)"
        v-else-if="item.cover.length > 1 && item.type == 1"
      >
        <div class="top">{{ item.title }}</div>
        <div class="imgs">
          <img
            :src="FixUrl(obj.url)"
            alt=""
            v-for="obj in item.cover"
            :key="obj.id"
          />
        </div>
        <div class="bottom">
          <span class="nickname">{{ item.user.nickname }}</span>
          <span class="number"
            >{{
              item.comments ? item.comments.length : item.comment_length
            }}跟帖</span
          >
        </div>
      </div>
      <div class="movie" @click="getid(item.id)" v-else>
        <div class="top">{{ item.title }}</div>
        <div class="tv">
          <img
            :src="FixUrl(obj.url)"
            alt=""
            v-for="obj in item.cover"
            :key="obj.id"
          />
          <div class="myicon">
            <i class="iconfont iconshipin"></i>
          </div>
        </div>
        <div class="bottom">
          <span class="nickname">{{ item.user.nickname }}</span>
          <span class="number"
            >{{
              item.comments ? item.comments.length : item.comment_length
            }}跟帖</span
          >
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ["info"],
  methods: {
    FixUrl(url) {
      if (url.startsWith("http")) {
        return url;
      } else {
        return this.$axios.defaults.baseURL + url;
      }
    },
    getid(id) {
      this.$emit("infoId", id);
    },
  },
};
</script>

<style scoped lang='less'>
.MyLove {
  .Love {
    .top {
      font-size: 14px;
    }
    .bottom {
      .nickname {
        margin-right: 10px;
      }
    }
    .one {
      border-bottom: 1px solid black;
      display: flex;
      padding: 10px;
      .left {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-around;
      }
      .right {
        img {
          height: 60px;
          width: 80px;
        }
      }
    }
    .three {
      border-bottom: 1px solid black;
      padding: 10px;
      .imgs {
        display: flex;
        justify-content: space-around;
        img {
          height: 80px;
          width: 90px;
          object-fit: contain;
        }
      }
    }
    .movie {
      padding: 10px;
      border-bottom: 1px solid black;
      .tv {
        position: relative;
        margin-bottom: 10px;
        .myicon {
          border-radius: 50%;
          height: 50px;
          width: 50px;
          background-color: rgba(0, 0, 0, 0.5);
          position: absolute;
          transform: translate(-50%, -50%);
          top: 50%;
          left: 50%;
          .iconfont {
            font-size: 50px;
            color: white;
          }
        }
        img {
          width: 350px;
          height: 150px;
          object-fit: contain;
        }
      }
    }
  }
}
</style>